package org.wiw.client.gui;

import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Abstract dialog box
 * @author yanik
 */
public abstract class AbstractDialogBox extends DialogBox {
	
	private VerticalPanel mainPanel;
	protected VerticalPanel dialogPanel;

	public AbstractDialogBox(String title) {
		super();
		setText(title);
		setAnimationEnabled(true);
		setModal(true);
		
		dialogPanel = new VerticalPanel();
		dialogPanel.addStyleName("dialogVPanel");
		
		mainPanel = new VerticalPanel();
		dialogPanel.addStyleName("dialogVPanel");
		
		dialogPanel.add(mainPanel);
				
		setWidget(dialogPanel);
	}
	
	@Override
	public void show() {
		createContent();
		super.show();
	}
	
	/**
	 * Called just before {@link #show()}
	 */
	protected abstract void createContent();
	
	public void add(Widget w){
		mainPanel.add(w);
	}
	
	public void add(String label,Widget w){
		add(new HTML(label));
		add(w);
	}
}
